cmake_minimum_required(VERSION 3.8)
project(agv_diagnostics)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
find_package(diagnostic_updater REQUIRED)
find_package(diagnostic_msgs REQUIRED)
# find_package(serial REQUIRED)


# find_library(LIBSERIAL_LIBRARIES NAMES serial PATHS /usr/lib/x86_64-linux-gnu)



if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

add_library(
  ${PROJECT_NAME}
  SHARED
  src/agv_diagnostics.cpp
  include/agv_diagnostics/agv_diagnostics.hpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
  "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
  "$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
# target_link_libraries(${PROJECT_NAME}    rclcpp  diagnostic_updater  diagnostic_msgs )
ament_target_dependencies(${PROJECT_NAME} rclcpp  diagnostic_updater  diagnostic_msgs    )
target_compile_definitions(${PROJECT_NAME} PRIVATE "ROBOT_CONTROLLER_BUILDING_DLL")

add_executable(
    agv_diagnostics_node
    src/agv_diagnostics.cpp 
    include/agv_diagnostics/agv_diagnostics.hpp)
ament_target_dependencies(agv_diagnostics_node rclcpp  diagnostic_updater  diagnostic_msgs     )

target_include_directories(agv_diagnostics_node PUBLIC
  "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
  "$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
install(TARGETS
agv_diagnostics_node
  DESTINATION lib/${PROJECT_NAME}
)
install(
  TARGETS
  ${PROJECT_NAME}
  RUNTIME DESTINATION bin
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
)
install(
  DIRECTORY include/
  DESTINATION include
)

ament_export_include_directories(
  include
)
ament_export_libraries(
   ${PROJECT_NAME}
)
ament_export_dependencies(
    rclcpp  diagnostic_updater  diagnostic_msgs   
)

ament_package()
